package com.project.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.LogBean;
import com.project.mapper.ILogMapper;
import com.project.service.ILogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

@Service
@Transactional
public class LogService implements ILogService {
    @Autowired
    private ILogMapper logMapper;

    @Override
    public IPage<LogBean> cutByItem(Integer pageNO, LocalDate startDate, LocalDate endDate) {
        QueryWrapper<LogBean> qw = new QueryWrapper<>();
        if (startDate != null) {
            qw.ge("l_date",startDate);
        }if (endDate != null) {
            qw.le("l_date",endDate);
        }
        return logMapper.selectPage(new Page<>(pageNO,2),qw);
    }

    @Override
    public void add(LogBean logBean) {
        logMapper.insert(logBean);
    }
}
